<?php
uses('sanitize');
class AppController extends Controller {
	var $authAllow = array();
	var $components = array('Auth');
	var $helpers = array('Html', 'Javascript', 'Form', 'Text', 'Time', 'Markdown');
	var $uses = array('User');
	
	function beforeFilter(){
		parent::beforeFilter();
		if(isset($this->Auth)){
			// allow this action if it's configured to be allowed.
			foreach($this->authAllow as $allowAction){
				$this->Auth->allow($allowAction);
			}
			// Set some Auth settings.
			$this->Auth->fields = array('username' => 'login', 'password' => 'pass');
			$this->Auth->loginAction = '/admin/login';
			$this->Auth->loginRedirect = '/admin';
			$this->Auth->logoutRedirect = '/admin/login';
			$this->Auth->loginError = 'Invalid username / password combination. Please try again.';
			$this->Auth->autoRedirect = false;
			$this->Auth->userScope = array('User.active' => 1, 'User.admin' => 1);
			$this->Auth->authenticate = $this->User;
		}
	}
}
?>
